/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package main;

import database.DataEngine;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import log.LogDef;
import utils.ConfigReaderSlave;
import utils.Debug;
import utils.Def;

/**
 * @author Administrator
 */
public class Main {

    private static int numberRobot = 10;
    private static int numberRobotInTable = 3;
    private static int roomId = 0;
    private static int tableId = 0;
    private static int choose = 0;

    public static void main(String[] args) {
        ConfigReaderSlave configReaderSlave = new ConfigReaderSlave();
        String address = configReaderSlave.getValue(Def.STR_SLAVE_IPADDR);
        String port = configReaderSlave.getValue(Def.STR_SLAVE_PORT);
        String number = configReaderSlave.getValue(Def.NUMBER_ROBOT);
        String dbAdress = configReaderSlave.getValue(Def.STR_DB_IPADDR);
        String dbPort = configReaderSlave.getValue(Def.STR_DB_PORT);
        String dbUser = configReaderSlave.getValue(Def.STR_DB_USERNAME);
        String dbPass = configReaderSlave.getValue(Def.STR_DB_PASSWORD);
        String dbSchema = configReaderSlave.getValue(Def.STR_DB_SID);
        String logFilePath = configReaderSlave.getValue(Def.LOGFILE_LOCATION);

        DataEngine dataEngine = DataEngine.getInstance();
        Debug.d("pass :" + dbPass);
//        dataEngine.setConfig(dbAdress, Integer.parseInt(dbPort), dbUser, dbPass, dbSchema, dbSchema);
        dataEngine.connectToDabatabase();
        numberRobot = Integer.parseInt(number);
        Debug.d("number robot :" + numberRobot);
        DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
        Date date = new Date();
        BotManager botManager = new BotManager(numberRobot, address, port);
        botManager.setLogFilePath(logFilePath);
        botManager.logUserStatus("start robot :" + dateFormat.format(date), LogDef.LOG_LEVEL.LOG_INFO);
        botManager.start();
    }
}
